#include "rclcpp/rclcpp.hpp"
#include "rclcpp_components/register_node_macro.hpp"
#include "robot_msgs/msg/autoaim_info.hpp"
#include "std_msgs/msg/int32.hpp"
#include "robot_msgs/msg/robot_blood_info.hpp"
#include "nav_msgs/msg/odometry.hpp"


using namespace std::chrono_literals;

namespace topic_pub_node {
    class TopicPublisher : public rclcpp::Node {
    public :
        rclcpp::Publisher<std_msgs::msg::Int32>::SharedPtr publisher_1;
        rclcpp::Publisher<robot_msgs::msg::AutoaimInfo>::SharedPtr publisher_2;
        rclcpp::Publisher<robot_msgs::msg::RobotBloodInfo>::SharedPtr publisher_3;
        rclcpp::Publisher<std_msgs::msg::Int32>::SharedPtr publisher_4;
        rclcpp::Publisher<nav_msgs::msg::Odometry>::SharedPtr publisher_5;
        
        TopicPublisher(const rclcpp::NodeOptions &options = rclcpp::NodeOptions())
                : Node("minimal_rmcv_bridge"),
                  timer_(this->create_wall_timer(std::chrono::milliseconds(1000), [this] { behaviour_publish(); })) {
                  publisher_1 = this->create_publisher<std_msgs::msg::Int32>("/game_time", 10);
                  publisher_4 = this->create_publisher<std_msgs::msg::Int32>("/vitual_mode", 10);
                  publisher_2 = this->create_publisher<robot_msgs::msg::AutoaimInfo>("/autoaim2decision", 10);
                  publisher_3 = this->create_publisher<robot_msgs::msg::RobotBloodInfo>("/robot_blood_info", 10);
                  publisher_5 = this->create_publisher<nav_msgs::msg::Odometry>("/Odometry", 10);
        }

        void behaviour_publish() {
            std_msgs::msg::Int32 msg;
            robot_msgs::msg::AutoaimInfo msg2;
            robot_msgs::msg::RobotBloodInfo msg3;
            robot_msgs::msg::RobotInfo data1;
            robot_msgs::msg::RobotBattleState data2;
            data2.id = 0,data2.blood = 100;
            data1.id = 0,data1.pos.x = 8,data1.pos.y = 8,data1.pos.z = 0;
            
            msg.data = 2;
            publisher_1->publish(msg);

            msg2.data.push_back(data1);
            msg3.data.push_back(data2);
            
            publisher_2->publish(msg2);
            publisher_3->publish(msg3);
            publisher_4->publish(msg);
            
            nav_msgs::msg::Odometry msg5;
            msg5.pose.pose.position.x = 8.640000 - 2.898;
            msg5.pose.pose.position.y = 1.055762 - 3.335;
            msg5.pose.pose.position.z = 0.0;
            publisher_5->publish(msg5);
        }

    private :
        rclcpp::TimerBase::SharedPtr timer_;
    };
}


RCLCPP_COMPONENTS_REGISTER_NODE(topic_pub_node::TopicPublisher)
